package com.apksources.torch;

import java.io.IOException;

import android.content.Context;
import android.hardware.Camera;
import android.view.SurfaceHolder;
import android.view.SurfaceView;

public class MySurfaceView extends SurfaceView implements SurfaceHolder.Callback {

	private SurfaceHolder mHolder;
	public Camera mCamera;

	@SuppressWarnings("deprecation")
	public MySurfaceView(Context context) {
		super(context);
		this.mHolder = getHolder();
		this.mHolder.addCallback(this);
		this.mHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
	}

	@Override
	public void surfaceChanged(SurfaceHolder surfaceHoder, int format, int width, int height) {
		mCamera.startPreview();
	}

	@Override
	public void surfaceCreated(SurfaceHolder surfaceHoder) {
		try {
			mCamera.setPreviewDisplay(mHolder);
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	@Override
	public void surfaceDestroyed(SurfaceHolder surfaceHoder) {
		// TODO Auto-generated method stub

	}

}
